﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FX_API.Models
{
    public class FiltersItem
    {
        /// <summary>
        /// 字段名
        /// </summary>
        public string field_name { get; set; }
        /// <summary>
        /// 取值范围
        /// </summary>
        public List<string> field_values { get; set; }
        /// <summary>
        /// 支持操作
        /// </summary>
        [JsonProperty(PropertyName = "operator")]
        public string _operator { get; set; }
    }

    public class OrdersItem
    {
        /// <summary>
        /// 字段名
        /// </summary>
        public string fieldName { get; set; }
        /// <summary>
        /// 如果是true，按照升序排列，如果是false，则按照倒序排列
        /// </summary>
        public string isAsc { get; set; }
    }

    public class Search_query_info
    {
        /// <summary>
        /// 获取数据条数, 最大值为100
        /// </summary>
        public int limit { get; set; }
        /// <summary>
        /// 偏移量，从0开始、数值必须为limit的整数倍
        /// </summary>
        public int offset { get; set; }
        /// <summary>
        /// 过滤条件列表
        /// </summary>
        public List<FiltersItem> filters { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        public List<OrdersItem> orders { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public List<string> fieldProjection { get; set; }
    }

    public class Data
    {
        /// <summary>
        /// 对象的api_name
        /// </summary>
        public string dataObjectApiName { get; set; }
        /// <summary>
        /// 查询条件列表
        /// </summary>
        public Search_query_info search_query_info { get; set; }

        public override string ToString()
        {
            return JsonConvert.SerializeObject(this);
        }
    }

    public class FXQueryInfo
    {
        /// <summary>
        /// 企业应用访问公司合法性凭证
        /// </summary>
        public string corpAccessToken { get; set; }
        /// <summary>
        /// 企业ID
        /// </summary>
        public string corpId { get; set; }
        /// <summary>
        /// 当前操作人OpenUserID
        /// </summary>
        public string currentOpenUserId { get; set; }
        /// <summary>
        /// 查询条件
        /// </summary>
        public Data data { get; set; }
    }
}
